﻿using System;

class QuadraticEquationAndRoots

            // Write a program that enters the coefficients a, b and c of a quadratic equation a*x2 + b*x + c = 0 and calculates and prints its real roots. 
            // Note that quadratic equations may have 0, 1 or 2 real roots.

{
    static void Main()
    {
        Console.WriteLine("Enter value for 'a':");
        double a = double.Parse(Console.ReadLine());
        Console.WriteLine("Enter value for 'b':");
        double b = double.Parse(Console.ReadLine());
        Console.WriteLine("Enter value for 'c':");
        double c = double.Parse(Console.ReadLine());
        double x;
        double x1;
        double x2;
        double d = (b * b) - (4 * a * c);
        if (a == 0)
        {
            Console.WriteLine("This is a linear equation!");
        }
        else if (d < 0)
        {
            Console.WriteLine("The equation has no real roots");
        }
        else if (d == 0)
        {
            x = -b / (2 * a);
            Console.WriteLine("The equation has only one root - {0}", x);
        }
        else
        {
            x1 = (-b + Math.Sqrt(d) / 2 * a);
            x2 = (-b - Math.Sqrt(d) / 2 * a);
            Console.WriteLine("The equation has two real roots - {0} and {1}", x1, x2);
        }
    }
}

